
package com.compuvest.web;

public class Address implements java.io.Serializable {

// <editor-fold defaultstate="collapsed" desc="init">
    private String company;
    private String firstName;
    private String lastName;
    private String address1;
    private String address2;
    private String city;
    private String country;
    private String state;
    private String zip;
    private String zip4;
    private String phone;
    private String cell;
    private String fax;
// </editor-fold>

// <editor-fold defaultstate="collapsed" desc="Address()">
    public Address() {
	this("", "", "", "", "", "", "", "", "", "", "", "", "");
    }

    public Address(String company, String firstName, String lastName, String address1, String address2, String city, String country, String state, String zip, String zip4, String phone, String cell, String fax) {
	this.company = company;
	this.firstName = firstName;
	this.lastName = lastName;
	this.address1 = address1;
	this.address2 = address2;
	this.city = city;
	this.country = country;
	this.state = state;
	this.zip = zip;
	this.zip4 = zip4;
	this.phone = phone;
	this.cell = cell;
	this.fax = fax;
    }
// </editor-fold>

    public String getFirstName()		{ return firstName; }
    public void setFirstName(String firstName)	{ this.firstName = cleanString(firstName); }

    public String getLastName()			{ return lastName; }
    public void setLastName(String lastName)	{ this.lastName = cleanString(lastName); }

    public String getName()			{ return getFirstName() + " " + getLastName(); }

    public String getCompany()			{ return company; }
    public void setCompany(String company)	{ this.company = cleanString(company); }

    public String getAddress1()			{ return address1; }
    public void setAddress1(String address1)	{ this.address1 = cleanString(address1); }

    public String getAddress2()			{ return address2; }
    public void setAddress2(String address2)	{ this.address2 = cleanString(address2); }

    public String getCity()			{ return city; }
    public void setCity(String city)		{ this.city = cleanString(city); }

    public String getState()			{ return state; }
    public void setState(String state)		{ this.state = cleanString(state); }

    public String getCountry()			{ return country; }
    public void setCountry(String country)	{ this.country = cleanString(country); }

    public String getZip()			{ return zip; }
    public void setZip(String zip)		{ this.zip = cleanString(zip); }

    public String getZip4()			{ return zip4; }
    public void setZip4(String zip4)		{ this.zip4 = cleanString(zip4); }

    public String getPhone()			{ return phone; }
    public void setPhone(String phone)		{ this.phone = cleanString(phone); }

    public String getCell()			{ return cell; }
    public void setCell(String cell)		{ this.cell = cleanString(cell); }

    public String getFax()			{ return fax; }
    public void setFax(String fax)		{ this.fax = cleanString(fax); }

// <editor-fold defaultstate="collapsed" desc="cleanString()">

    private String cleanString(String str) {
	return str == null ? "" : str.trim();
    }
// </editor-fold>

// <editor-fold defaultstate="collapsed" desc="toString()">

    @Override
    public String toString() {

        StringBuilder buf = new StringBuilder();
        buf.append("\nCompany: ").append(getCompany());
        buf.append("\nName: ").append(getFirstName()).append(" ").append(getLastName());
        buf.append("\nAddress: ").append(getAddress1()).append(getAddress2().isEmpty() ? "" : "\n\t" + getAddress2());
        buf.append("\n").append(getCity()).append(", ").append(getState()).append(" ").append(getZip()).append(getZip4().isEmpty() ? "" : "-" + getZip4()).append(" ").append(getCountry());
        buf.append(getPhone().isEmpty() ? "" : "\nPhone: " + getPhone());
        buf.append(getCell().isEmpty() ? "" : "\nCell: " + getCell());
        buf.append(getFax().isEmpty() ? "" : "\nFax: " + getFax());

        return buf.toString();
    }
// </editor-fold>

}
